package com.example.homework9;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.fragment.app.Fragment;

import com.example.homework9.service.MusicService;

public class Fragment4_1 extends Fragment {
    public Fragment4_1(){
        super(R.layout.fragment4_1);
    }
    private Button playMusicButton, stopMusicButton;

    public void onViewCreated(View view, Bundle savedInstanceState){
        playMusicButton = getView().findViewById(R.id.playMusicButton);
        playMusicButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), MusicService.class);
                getActivity().startService(intent);
            }
        });

        stopMusicButton = getView().findViewById(R.id.stopMusicButton);
        stopMusicButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), MusicService.class);
                getActivity().stopService(intent);
            }
        });
    }
}